define(['egis'], function (egis) {
    Window.deserializer = Window.deserializer || new egis.core.Deserializer();
    Window.container = Window.container || {};
    dsBridge.register('create_RestWBASService', function (sourceId, url, authType, clientId, clientSecret,tokenUrl) {
        var restGeoService = new egis.ews.RestWBASService({
            url: url,
            deserializer: Window.deserializer,
            authType: authType,
            clientId: clientId,
            clientSecret: clientSecret,
            tokenUrl:tokenUrl
        });
        Window.container[sourceId] = restGeoService;
    })

    dsBridge.registerAsyn('RestWBASService_getCapabilities', function (sourceId, format, responseCallback) {
        var restWBASService = Window.container[sourceId];
        restWBASService.getCapabilities(format).then(function (value) {
            responseCallback(JSON.stringify(value));
        })
    })

    dsBridge.registerAsyn('RestWBASService_simplyBuffer', function (sourceId, simpleBufferInput, responseCallback) {
        var restWBASService = Window.container[sourceId];
        simpleBufferInput = Window.deserializer.createJsInstance(JSON.parse(simpleBufferInput));
        restWBASService.bufferAnalysis(simpleBufferInput).then(function (value) {
            responseCallback(JSON.stringify(value));
        })
    })

    dsBridge.registerAsyn('RestWBASService_bufferAnalysis', function (sourceId, bufferAnalysisInput, responseCallback) {
        var restWBASService = Window.container[sourceId];
        bufferAnalysisInput = Window.deserializer.createJsInstance(JSON.parse(bufferAnalysisInput));
        restWBASService.bufferAnalysis(bufferAnalysisInput).then(function (value) {
            responseCallback(JSON.stringify(value));
        })
    })

    dsBridge.registerAsyn('RestWBASService_topoOperationAnalysis', function (sourceId, topoOperationInput, responseCallback) {
        var restWBASService = Window.container[sourceId];
        topoOperationInput = Window.deserializer.createJsInstance(JSON.parse(topoOperationInput));
        restWBASService.topoOperationAnalysis(topoOperationInput).then(function (value) {
            responseCallback(JSON.stringify(value));
        })
    })

    dsBridge.registerAsyn('RestWBASService_topoRelationAnalysis', function (sourceId, topoRelationInput, responseCallback) {
        var restWBASService = Window.container[sourceId];
        topoRelationInput = Window.deserializer.createJsInstance(JSON.parse(topoRelationInput));
        restWBASService.topoRelationAnalysis(topoRelationInput).then(function (value) {
            responseCallback(JSON.stringify(value));
        })
    })
})